package lambdasinaction.chap11;

import java.util.concurrent.Future;

public class AsyncShopClient {

    public static void main(String[] args) {

        AsyncShop shop = new AsyncShop("最好的店");//查询商店
        long start = System.nanoTime();

        Future<Double> futurePrice = shop.getPrice("华为手机");

        long incocationTime = ((System.nanoTime() - start) / 1_000_000);
        System.out.println("调用返回后" + incocationTime + " msecs");

        try {
            System.out.println("获取后价格1 " + futurePrice.get());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        long retrivalTime = ((System.nanoTime() - start) / 1_000_000);
        System.out.println("返回后时间 " + retrivalTime + " msecs");
    }
}